<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>教务员-导出学生实习信息</title>
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/css/index.css">
</head>
<body>
<div class="body-head"><span>学生实习信息管理&nbsp;>&nbsp;导出生实习信息</span></div>
<div class="demoTable">
    <label class="layui-form-label">毕业年份：</label>
    <div class="layui-inline">
        <input class="layui-input" type="text" id="yearSelector" name="yearSelector">
    </div>
    <button class="layui-btn layui-btn-sm" data-type="reload" id="year-btn">一键导出</button>
</div>

<script src="${ctx}/static/js/jquery.min.js"></script>
<script src="${ctx}/static/layui/layui.js" charset="utf-8"></script>
<script src="${ctx}/static/js/index.js"></script>
<script>
    layui.use(['laydate', 'jquery', 'layer'], function () {
        let $ = layui.$;
        let laydate = layui.laydate;
        let layer = layui.layer;

        laydate.render({
            elem: '#yearSelector', //指定元素
            type: 'year'
        });


        $('#year-btn').on('click', function () {
            let year = $("#yearSelector").val();
            if (year != "") {
                layer.confirm("确定要导出" + year + "年的数据吗？",{btn: ['确定', '取消'], title: "提示"},function () {
                    $.ajax({
                        type: "post",
                        url: "${ctx}/academic/exportInternship.action",
                        data: {yearSelector:year},
                        dataType: "json",
                        success: function (data) {
                            //console.log(data);
                            if (data.flag) {
                                layer.msg("导出成功");
                            } else {
                                layer.msg("导出失败, 不存在数据");
                            }
                        },
                        error: function () {
                            layer.msg("请求失败");
                        }
                    })

                })
            } else {
                layer.msg("请选择年份");
                return;
            }

        });
    });
</script>
</body>
</html>
